package 天梯赛.A.A9;



import java.util.*;
import java.util.stream.Collectors;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int k = sc.nextInt();
        int sum = 0;
        List<Student> people = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            String str = sc.next();
            int score = sc.nextInt();
            if (score >= m) {
                sum += 50;
            }
            if (score < m && score >= 60) {
                sum += 20;
            }
            Student s = new Student(str, score);
            people.add(s);
        }
        System.out.println(sum);
        Collections.sort(people);
        //打印符合条件的分数

        //根据成绩进行分组
        Map<Integer, List<Student>> collect = people.stream().collect(Collectors.groupingBy(Student::getScore));
        List<Integer> collect1 = people.stream().map(Student::getScore).distinct().collect(Collectors.toList());

        int count=1;
        for (int i = 0; i < collect1.size(); i++) {
            if (count>k){
                break;
            }
            int x = collect1.get(i);
            List<Student> students = collect.get(x);
            for (int l = 0; l < students.size(); l++) {
                System.out.println(count+" "+students.get(l).qq+" "+students.get(l).score);
            }
            count+=students.size();
        }

//        List<Integer> list = new ArrayList<>();
//        int count=0;
//        //最后的集合
//
//
//        for (int i = 0; i < people.size(); i++) {
//            Student student=people.get(i);
//            if (count==5){
//                break;
//            }
//            if (!list.contains(student.getScore())) {
//                count++;
//            }
//            //不是count++的原因 是如果后面还有分组?
//            list.add(student.score);
//            last.add(student);
//        }
//        Collections.sort(last);
//        for (int i = 0; i < last.size(); i++) {
//            System.out.println(last.get(i).score);
//        }
    }

    static class Student implements Comparable<Student> {
        @Override
        public int compareTo(Student o) {
            if (this.score < o.score) {
                return 1;
            } else if (this.score > o.score) {
                return -1;
            } else if (this.score == o.score) {
                return this.qq.compareTo(o.qq);
            }
            return 0;
        }

        public String qq;
        public Integer score;

        public Student(String qq, int score) {
            this.qq = qq;
            this.score = score;
        }

        public String getQq() {
            return qq;
        }

        public void setQq(String qq) {
            this.qq = qq;
        }

        public int getScore() {
            return score;
        }

        public void setScore(int score) {
            this.score = score;
        }
    }
}
